import request from '../utils/request'

// 添加评论或评论回复
export function addApplyComments (data) {
  return request({
    url: 'v1_0/comments',
    method: 'POST',
    needToken: true,
    data: data
  })
}

// 举报文章
export function reportArticle (data) {
  return request({
    url: 'v1_0/article/reports',
    method: 'POST',
    needToken: true,
    data: data
  })
}

// 取消对文章不喜欢
export function cancelDislike (params) {
  return request({
    url: `v1_0/article/dislikes/${params}`,
    method: 'DELETE',
    needToken: true
  })
}

// 取消对文章点赞
export function cancelGiveLike (params) {
  return request({
    url: `v1_0/article/likings/${params}`,
    method: 'DELETE',
    needToken: true
  })
}

// 取消对评论或评论回复点赞
export function cancelCommentsOrApplyGiveLike (data) {
  return request({
    url: `v1_0/comment/likings/${data}`,
    method: 'DELETE',
    needToken: true
  })
}

// 取消收藏文章
export function cancelCollectedArticle (data) {
  return request({
    url: `v1_0/article/collections/${data}`,
    method: 'DELETE',
    needToken: true,
    data: data
  })
}

// 对文章不喜欢
export function DislikeArticle (data) {
  return request({
    url: 'v1_0/article/dislikes',
    method: 'POST',
    needToken: true,
    data: data
  })
}

// 对文章点赞
export function GiveLikeArticle (data) {
  return request({
    url: 'v1_0/article/likings',
    method: 'POST',
    needToken: true,
    data: data
  })
}

// 对评论或评论回复点赞
export function GiveLikeCommentsOrApply (data) {
  return request({
    url: 'v1_0/comment/likings',
    method: 'POST',
    needToken: true,
    data: data
  })
}

// 收藏文章
export function getCollectArticle (data) {
  return request({
    url: 'v1_0/article/collections',
    method: 'POST',
    needToken: true,
    data
  })
}

// 全部频道列表
export function getAllChannelList (params) {
  return request({
    url: 'v1_0/channels',
    method: 'GET',

    params: params
  })
}

// 获取当前用户文章列表
export function getCurrentUserArticleList (params) {
  return request({
    url: 'v1_0/user/articles',
    method: 'GET',
    needToken: true,
    params: params
  })
}

// 获取新闻文章详情
export function getNewsArticleDetail (params) {
  return request({
    url: `v1_0/articles/${params}`,
    method: 'GET',
    needToken: true
  })
}

// 获取用户收藏列表
export function getUserCollectionList (params) {
  return request({
    url: 'v1_0/article/collections',
    method: 'GET',
    needToken: true,
    params: params
  })
}

// 获取用户文章列表
export function getUserArticleList (params) {
  return request({
    url: 'v1_0/users/:user_id/articles',
    method: 'GET',
    needToken: true,
    params: params
  })
}

// 获取用户阅读历史
export function getUserReadHistory (params) {
  return request({
    url: 'v1_0/user/histories',
    method: 'GET',
    needToken: true,
    params: params
  })
}

// 获取评论或评论回复
export function getCommentsOrApply (type, source, offset, limit) {
  return request({
    url: 'v1_0/comments',
    method: 'GET',
    needToken: true,
    params: { type, source, offset, limit }
  })
}

// 阅读时长埋点反馈

export function readDurationBuriedPointFeedback (data) {
  return request({
    url: 'v1_0/reading/durations',
    method: 'POST',
    needToken: true,
    data: data
  })
}

// 频道新闻推荐_V1.1
export function channelNewsRecommend11 (params) {
  return request({
    url: 'v1_1/articles',
    method: 'GET',
    needToken: true,
    params: params
  })
}

// 获得用户文章详情列表
export function approachUserList (target) {
  return request({
    url: `v1_0/users/${target}/articles`,
    needToken: true
  })
}
